package com.ustcinfo.ishare.kafka.monitor.service.impl;

import com.ustcinfo.ishare.kafka.monitor.bean.KafkaMonitorInfo;
import com.ustcinfo.ishare.kafka.monitor.dao.IKafkaMonitorInfoDao;
import com.ustcinfo.ishare.kafka.monitor.service.IKafkaInfoService;
import com.ustcinfo.ishare.kafka.monitor.utils.GetAllKafkaInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * Created by Shinelon on 2018/3/24.
 */
@Service("kafkaInfoService")
public class KafkaInfoServiceImpl implements IKafkaInfoService {

    @Autowired
    private IKafkaMonitorInfoDao kafkaMonitorInfoDao;
    @Autowired
    GetAllKafkaInfo getAllKafkaInfo ;

    @PostConstruct
    public void getAllKafkaInfo() {
        getAllKafkaInfo.getAllInfo();
    }

    public void insert(KafkaMonitorInfo kafkaMonitorInfo) {
        kafkaMonitorInfoDao.insert(kafkaMonitorInfo);
    }

    public void removeAll() {
        kafkaMonitorInfoDao.removeAll();
    }

    public void removeByTopic(String topic) {
        kafkaMonitorInfoDao.removeByTopic(topic);
    }

    public List<KafkaMonitorInfo> findKafkaMonitorInfoByTopic(String topic) {
        return kafkaMonitorInfoDao.findKafkaMonitorInfoByTopic(topic);
    }

    public List<KafkaMonitorInfo> findAllKafkaMonitorInfo() {
        return kafkaMonitorInfoDao.findAllKafkaMonitorInfo();
    }

    public List<KafkaMonitorInfo> findKafkaMonitorInfoByPage(int start, int size) {
        return kafkaMonitorInfoDao.findKafkaMonitorInfoByPage(start, size);
    }

    public List<KafkaMonitorInfo> findKafkaMonitorInfo(String topicName, String groupName, Long beginTime, Long endTime) {
        return kafkaMonitorInfoDao.findKafkaMonitorInfo(topicName,groupName,beginTime,endTime);
    }
}
